import java.util.Scanner;

public class Test2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        int m  = scanner.nextInt();
        int k = scanner.nextInt();

        int[] w = new int[n];
        int[] value =  new int[n];

        for (int i = 0; i < n; i++) {
            w[i] = scanner.nextInt();
            value[i] = scanner.nextInt();
        }

        boolean[][] noCanBuy = new boolean[n][n];
        for (int i = 0; i < k; i++) {
            int x = scanner.nextInt() -1;
            int y = scanner.nextInt() - 1;
            noCanBuy[x][y] = true;
            noCanBuy[y][x] = true;
        }

        //初始化dp
        int[][] dp = new int[n+1][m+1];
        for (int i = 1; i <=n ; i++) {
            for (int j = 0; j <= m; j++) {
                dp[i][j] = dp[i-1][j];
                if(j >= w[i-1]){
                    boolean canBuy = true;
                    for (int l = 0; l < i - 1; l++) {
                        if(noCanBuy[i-1][l] && dp[l+1][j-w[i-1]] == dp[i-1][j-w[i-1]] ){
                            canBuy = false;
                            break;
                        }
                    }
                    if(canBuy){
                        dp[i][j] = Math.max(dp[i][j],dp[i-1][j-w[i-1]] + value[i-1]);
                    }
                }
            }
        }
        int max = 0;
        for (int i = 0; i <= m; i++) {
            max = Math.max(max,dp[n][i]);
        }
        System.out.println(max);
    }
}
